<template>
  <!--header section start-->
  <header class="header">
    <div class="container">
      <div class="header__wrapper">
        <div class="header__logo">
          <a href="index.html">
            <img src="./assets/images/logo.png" alt="logo">
          </a>
        </div>
        <div class="header__nav" :class="{ shown: isNavShown }">
          <ul class="header__nav-primary">
            <li><a href="#">Home</a></li>
            <li><a href="#">Features</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Download</a></li>
          </ul>
          <span @click="toggleNav"><i class="fas fa-times"></i></span>
        </div>
        <div class="header__bars" @click="toggleNav">
          <div class="header__bars-bar header__bars-bar-1"></div>
          <div class="header__bars-bar header__bars-bar-2"></div>
          <div class="header__bars-bar header__bars-bar-3"></div>
        </div>
      </div>
    </div>
  </header>
  <!--header section end-->
</template>

<script lang="ts" name="HeaderComponent" setup>
import { ref } from 'vue'
// 1-管理侧边栏展开和关闭
let isNavShown = ref(false); // 状态管理
function toggleNav() {
    console.log("管理侧边栏展开和关闭"+isNavShown.value)
    isNavShown.value = !isNavShown.value; // 切换状态
    // 获取页面元素-进行视图切换
    const navElement = document.querySelector('.header__nav') as HTMLElement;
      if (isNavShown.value) {
        console.log("navElement.style.right = '0'")
        navElement.style.right = '0';
      } else {
        navElement.style.right = '100%';
        console.log("navElement.style.right = '100%'")
      }
};

// 2-点击进行路由跳转

</script>

<style lang="css">
#app{
  padding: 0;
}
</style>
